
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>pypcd.nea_pc_format &#8212; pypcd 0.1.1 documentation</title>
    <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" src="../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
   
  <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for pypcd.nea_pc_format</h1><div class="highlight"><pre>
<span></span>
<span class="kn">import</span> <span class="nn">copy</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">sensor_msgs.msg</span> <span class="k">import</span> <span class="n">PointField</span>

<span class="c1"># these are from numpy_pc2</span>
<span class="n">_pftype_to_nptype</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">([(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT8</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;int8&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;uint8&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT16</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;int16&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT16</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;uint16&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT32</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;int32&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;uint32&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;float32&#39;</span><span class="p">)),</span>
                          <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">&#39;float64&#39;</span><span class="p">))])</span>

<span class="n">_pftype_to_pcd_letter</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">([(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT8</span><span class="p">,</span> <span class="s1">&#39;I&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span> <span class="s1">&#39;U&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT16</span><span class="p">,</span> <span class="s1">&#39;I&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT16</span><span class="p">,</span> <span class="s1">&#39;U&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT32</span><span class="p">,</span> <span class="s1">&#39;I&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span> <span class="s1">&#39;U&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span> <span class="s1">&#39;F&#39;</span><span class="p">),</span>
                              <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span> <span class="s1">&#39;F&#39;</span><span class="p">)])</span>

<span class="n">_pftype_to_size</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">([(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT8</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT16</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT16</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT32</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span> <span class="mi">8</span><span class="p">)])</span>


<span class="n">_nea_field_dicts</span> <span class="o">=</span> <span class="p">[</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;x&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;y&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;z&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;x_origin&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;y_origin&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">32</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;z_origin&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">40</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;range_variance&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">48</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;x_variance&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">52</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;y_variance&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">56</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;z_variance&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;reflectance&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">64</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;time_sec&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">68</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;time_nsec&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">72</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">},</span>
    <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;return_type&#39;</span><span class="p">,</span>
     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">76</span><span class="p">,</span>
     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span>
     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
     <span class="p">}]</span>

<span class="n">_nea_float_fields_dicts</span> <span class="o">=</span> <span class="p">[</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;x&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;y&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;z&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;x_origin&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;y_origin&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;z_origin&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;range_variance&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;x_variance&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">28</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;y_variance&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">32</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;z_variance&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">36</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;reflectance&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">40</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;time_sec&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">44</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;time_nsec&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">48</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">},</span>
                          <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;return_type&#39;</span><span class="p">,</span>
                           <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">52</span><span class="p">,</span>
                           <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span>
                           <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span>
                           <span class="p">}]</span>


<span class="n">_label_field_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;label&#39;</span><span class="p">,</span>
                     <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                     <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span>
                     <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">}</span>


<span class="c1"># TODO if I use &#39;_&#39; for padding, like pcl, there are weird</span>
<span class="c1"># interactions when using binary_compressed. PCL assumes</span>
<span class="c1"># padding is not included in compressed files (which makes sense).</span>
<span class="n">_padding_field_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;_PAD&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                       <span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span>
                       <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span>


<div class="viewcode-block" id="datatype_to_size"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.datatype_to_size">[docs]</a><span class="k">def</span> <span class="nf">datatype_to_size</span><span class="p">(</span><span class="n">datatype</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; ROS pointfield datatype to size in bytes</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">datatype</span> <span class="ow">in</span> <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT8</span><span class="p">,</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT8</span><span class="p">):</span>
        <span class="k">return</span> <span class="mi">1</span>
    <span class="k">elif</span> <span class="n">datatype</span> <span class="ow">in</span> <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT16</span><span class="p">,</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT16</span><span class="p">):</span>
        <span class="k">return</span> <span class="mi">2</span>
    <span class="k">elif</span> <span class="n">datatype</span> <span class="ow">in</span> <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">INT32</span><span class="p">,</span> <span class="n">PointField</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span> <span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT32</span><span class="p">):</span>
        <span class="k">return</span> <span class="mi">4</span>
    <span class="k">elif</span> <span class="n">datatype</span> <span class="ow">in</span> <span class="p">(</span><span class="n">PointField</span><span class="o">.</span><span class="n">FLOAT64</span><span class="p">,):</span></div>
        <span class="k">return</span> <span class="mi">8</span>


<div class="viewcode-block" id="make_nea_fields_dicts"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.make_nea_fields_dicts">[docs]</a><span class="k">def</span> <span class="nf">make_nea_fields_dicts</span><span class="p">(</span><span class="n">with_label</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">with_padding</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="n">field_dicts</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">_nea_field_dicts</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">with_label</span><span class="p">:</span>
        <span class="n">label_field_dict_copy</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">_label_field_dict</span><span class="p">)</span>
        <span class="c1"># TODO this assumes last field is return_type</span>
        <span class="n">label_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">field_dicts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span><span class="o">+</span><span class="mi">1</span>
        <span class="n">field_dicts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label_field_dict_copy</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">with_padding</span><span class="p">:</span>
        <span class="n">padding_field_dict_copy</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">_padding_field_dict</span><span class="p">)</span>
        <span class="c1"># TODO this assumes last field is return_type or label</span>
        <span class="n">padding_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">field_dicts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span><span class="o">+</span><span class="mi">1</span>
        <span class="k">if</span> <span class="n">with_label</span><span class="p">:</span>
            <span class="n">padding_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">padding_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span>
        <span class="n">field_dicts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">padding_field_dict_copy</span><span class="p">)</span></div>
    <span class="k">return</span> <span class="n">field_dicts</span>


<div class="viewcode-block" id="make_nea_float_fields_dicts"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.make_nea_float_fields_dicts">[docs]</a><span class="k">def</span> <span class="nf">make_nea_float_fields_dicts</span><span class="p">(</span><span class="n">with_label</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">with_padding</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="n">field_dicts</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">_nea_float_fields_dicts</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">with_label</span><span class="p">:</span>
        <span class="n">label_field_dict_copy</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">_label_field_dict</span><span class="p">)</span>
        <span class="c1"># TODO this assumes last field is return_type</span>
        <span class="n">label_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">field_dicts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span><span class="o">+</span><span class="mi">1</span>
        <span class="n">field_dicts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label_field_dict_copy</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">with_padding</span><span class="p">:</span>
        <span class="n">padding_field_dict_copy</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">_padding_field_dict</span><span class="p">)</span>
        <span class="c1"># TODO this assumes last field is return_type or label</span>
        <span class="n">padding_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">field_dicts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;offset&#39;</span><span class="p">]</span><span class="o">+</span><span class="mi">1</span>
        <span class="k">if</span> <span class="n">with_label</span><span class="p">:</span>
            <span class="n">padding_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">9</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">padding_field_dict_copy</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">10</span>
        <span class="n">field_dicts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">padding_field_dict_copy</span><span class="p">)</span></div>
    <span class="k">return</span> <span class="n">field_dicts</span>


<div class="viewcode-block" id="field_dict_list_to_dtypes"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.field_dict_list_to_dtypes">[docs]</a><span class="k">def</span> <span class="nf">field_dict_list_to_dtypes</span><span class="p">(</span><span class="n">field_dicts</span><span class="p">):</span>
    <span class="n">dtypes</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">field_dicts</span><span class="p">:</span>
        <span class="n">count</span> <span class="o">=</span> <span class="n">f</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span>
        <span class="k">if</span> <span class="n">count</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="n">count</span><span class="p">):</span>
                <span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">_</span><span class="si">%04d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">],</span> <span class="n">c</span><span class="p">)</span>
                <span class="n">nptype</span> <span class="o">=</span> <span class="n">_pftype_to_nptype</span><span class="p">[</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;datatype&#39;</span><span class="p">]]</span>
                <span class="n">dtypes</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">name</span><span class="p">,</span> <span class="n">nptype</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">name</span> <span class="o">=</span> <span class="n">f</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
            <span class="n">nptype</span> <span class="o">=</span> <span class="n">_pftype_to_nptype</span><span class="p">[</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;datatype&#39;</span><span class="p">]]</span>
            <span class="n">dtypes</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">name</span><span class="p">,</span> <span class="n">nptype</span><span class="p">))</span></div>
    <span class="k">return</span> <span class="n">dtypes</span>


<div class="viewcode-block" id="make_nea_dtypes"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.make_nea_dtypes">[docs]</a><span class="k">def</span> <span class="nf">make_nea_dtypes</span><span class="p">(</span><span class="n">with_label</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">with_padding</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="n">fl</span> <span class="o">=</span> <span class="n">make_nea_fields_dicts</span><span class="p">(</span><span class="n">with_label</span><span class="o">=</span><span class="n">with_label</span><span class="p">,</span>
                               <span class="n">with_padding</span><span class="o">=</span><span class="n">with_padding</span><span class="p">)</span></div>
    <span class="k">return</span> <span class="n">field_dict_list_to_dtypes</span><span class="p">(</span><span class="n">fl</span><span class="p">)</span>


<div class="viewcode-block" id="make_nea_float_dtypes"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.make_nea_float_dtypes">[docs]</a><span class="k">def</span> <span class="nf">make_nea_float_dtypes</span><span class="p">(</span><span class="n">with_label</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">with_padding</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="n">fl</span> <span class="o">=</span> <span class="n">make_nea_float_fields_dicts</span><span class="p">(</span><span class="n">with_label</span><span class="o">=</span><span class="n">with_label</span><span class="p">,</span>
                                     <span class="n">with_padding</span><span class="o">=</span><span class="n">with_padding</span><span class="p">)</span></div>
    <span class="k">return</span> <span class="n">field_dict_list_to_dtypes</span><span class="p">(</span><span class="n">fl</span><span class="p">)</span>


<div class="viewcode-block" id="field_dict_list_to_pcd_metadata"><a class="viewcode-back" href="../../pypcd.html#pypcd.nea_pc_format.field_dict_list_to_pcd_metadata">[docs]</a><span class="k">def</span> <span class="nf">field_dict_list_to_pcd_metadata</span><span class="p">(</span><span class="n">field_dict_list</span><span class="p">):</span>
    <span class="n">pcd_md</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;version&#39;</span><span class="p">:</span> <span class="o">.</span><span class="mi">7</span><span class="p">,</span>
              <span class="s1">&#39;fields&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">field_dict_list</span><span class="p">],</span>
              <span class="s1">&#39;size&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">_pftype_to_size</span><span class="p">[</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;datatype&#39;</span><span class="p">]]</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span>
                       <span class="n">field_dict_list</span><span class="p">],</span>
              <span class="s1">&#39;type&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">_pftype_to_pcd_letter</span><span class="p">[</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;datatype&#39;</span><span class="p">]]</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span>
                       <span class="n">field_dict_list</span><span class="p">],</span>
              <span class="s1">&#39;count&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">field_dict_list</span><span class="p">],</span>
              <span class="s1">&#39;width&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
              <span class="s1">&#39;height&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
              <span class="s1">&#39;viewpoint&#39;</span><span class="p">:</span> <span class="p">[</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">],</span>
              <span class="s1">&#39;points&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
              <span class="s1">&#39;data&#39;</span><span class="p">:</span> <span class="s1">&#39;ASCII&#39;</span><span class="p">}</span></div>
    <span class="k">return</span> <span class="n">pcd_md</span>

<span class="c1"># nea_fields = [ PointField(**d) for d in nea_fields_dicts]</span>
</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper"><div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../../index.html">Documentation overview</a><ul>
  <li><a href="../index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2018, Daniel Maturana.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.7.1</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>